<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles"
	prefix="tiles"%>
	
<rich:panel header="#{messages['agent.profile']}">
	<h:panelGrid>
		<h:outputText value="#{errorBean.errorMessage}" styleClass="error"></h:outputText>
	</h:panelGrid>

	<h:panelGrid width="100%">
		<h:outputText value="#{messages['agent.info']}" styleClass="sub_header" />
		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputText value="#{messages['instruction']}" styleClass="standardText_Instruction" />
		</h:panelGroup>
	</h:panelGrid>

	<t:panelGrid columns="2" columnClasses="standardTable_ColumnLeft_20,standardTable_ColumnLeft_80" width="100%">


		<h:outputText></h:outputText>
		<t:message for="code" styleClass="error"></t:message>

		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="code" value="#{messages['code']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
			<t:inputText id="code" readonly="true" required="true" size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.code}"></t:inputText>
		</h:panelGroup>
		
		<h:outputText></h:outputText>
		<t:message for="name" styleClass="error"></t:message>

		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="name" value="#{messages['contact.person']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
			<t:inputText id="name" required="true" size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.contactPerson}"></t:inputText>
		</h:panelGroup>
		
		<h:outputText></h:outputText>
		<t:message for="department" styleClass="error"></t:message>

		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="department" value="#{messages['department']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
			<t:inputText id="department" required="true" size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.deparment}"></t:inputText>
		</h:panelGroup>
		
		<h:outputText></h:outputText>
		<t:message for="vendorcode" styleClass="error"></t:message>

		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" />
			<h:outputLabel for="vendorcode" value="#{messages['vendor.code']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
			<t:inputText id="vendorcode" required="true" size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.vendorCode}"></t:inputText>
		</h:panelGroup>
		
		<h:outputText></h:outputText>
		<t:message for="telephone" styleClass="error"></t:message>
	    
	    <h:outputLabel for="telephone" value="#{messages['telephone.no']}" styleClass="standardText_Label" />
    	<t:inputText id="telephone" required="false" size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.telno}">
    		<t:validateRegExpr pattern="\d{2}-\d{8}"/>
    	</t:inputText>
	    
	    <h:outputText></h:outputText>
		<t:message for="fax" styleClass="error"></t:message>	
	    
	    <h:outputLabel for="fax" value="#{messages['fax.no']}" styleClass="standardText_Label" />
    	<t:inputText id="fax" required="false" size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.faxno}">
    		<t:validateRegExpr pattern="\d{2}-\d{8}"/>
    	</t:inputText>
		
		<h:outputText></h:outputText>
		<t:message for="email" styleClass="error"></t:message>
		
	   <h:panelGroup>
		   	<h:outputText value="*" styleClass="standardText_Mandatory" />	
		    <h:outputLabel for="email" value="#{messages['email']}" styleClass="standardText_Label" />
	   </h:panelGroup>
	   <h:panelGroup>
	   	<t:inputText id="email" readonly="true" required="true" size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.email}">
	   		<t:validateEmail></t:validateEmail>
	   	</t:inputText>
	   </h:panelGroup>

	</t:panelGrid>
	
	<h:panelGrid width="100%">
		<h:outputText value="#{messages['company.info']}"
			styleClass="sub_header" />
	</h:panelGrid>
	
	<t:panelGrid id="compInfo" columns="2" columnClasses="standardTable_ColumnLeft_20,standardTable_ColumnLeft_80" width="100%">
		<h:outputText></h:outputText>
		<t:message for="CompanyName" styleClass="error"></t:message>
		
		<h:panelGroup>
			 <h:outputText value="*" styleClass="standardText_Mandatory"/>
			<h:outputLabel for="CompanyName" value="#{messages['name']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<t:inputText id="CompanyName" size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.compName}"></t:inputText>
		
		<h:outputText></h:outputText>
		<t:message for="RegNo" styleClass="error"></t:message>
		
		<h:panelGroup>
			 <h:outputText value="*" styleClass="standardText_Mandatory"/>
			<h:outputLabel for="RegNo" value="#{messages['registration.no']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<t:inputText id="RegNo" size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.regNo}"></t:inputText>
   
		<h:outputText></h:outputText>
		<t:message for="CompanyAdress1" styleClass="error"></t:message>
		
		<h:panelGroup>
			 <h:outputText value="*" styleClass="standardText_Mandatory"/>
	    	<h:outputLabel for="CompanyAdress1" value="#{messages['address']}" styleClass="standardText_Label" />
		</h:panelGroup>
		<t:inputText id="CompanyAdress1" size="50" maxlength="50"  styleClass="standardText" value="#{agentProfileBean.agent.compAddress1}"></t:inputText>
	    
	    <h:outputText></h:outputText>
		<t:message for="CompanyAdress2" styleClass="error"></t:message>
	    
	    <h:panelGroup></h:panelGroup>
	    <h:panelGroup>
	    	<t:inputText id="CompanyAdress2" size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.compAddress2}"></t:inputText>
	    </h:panelGroup>
	    
	    <h:outputText></h:outputText>
		<t:message for="CompanyPostcode" styleClass="error"></t:message>
	    
	    <h:panelGroup>
			 <h:outputText value="*" styleClass="standardText_Mandatory" />
	    	<h:outputLabel for="CompanyPostcode" value="#{messages['postcode']}" styleClass="standardText_Label" />
	    </h:panelGroup>
    	<t:inputText id="CompanyPostcode" size="50" maxlength="5" styleClass="standardText" 
    	value="#{agentProfileBean.agent.compPostcode}">
    		<t:validateRegExpr pattern="\d{5}|\d{4}"/>
    	</t:inputText>
    	
    	<h:outputText></h:outputText>
		<t:message for="CompanyCity" styleClass="error"></t:message>
	    
	    <h:panelGroup>
			 <h:outputText value="*" styleClass="standardText_Mandatory"/>		
	    	<h:outputLabel for="CompanyCity" value="#{messages['city']}" styleClass="standardText_Label" />
	    </h:panelGroup>
        <t:inputText id="CompanyCity" size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.compCity}"></t:inputText>
	    
	    	
	    <h:outputText></h:outputText>
		<t:message for="CompanyCountry" styleClass="error"></t:message>
	    
	    <h:panelGroup>
			 <h:outputText value="*" styleClass="standardText_Mandatory"/>
	    <h:outputLabel for="CompanyCountry" value="#{messages['country']}" styleClass="standardText_Label" />
	    </h:panelGroup>
    	<t:selectOneMenu id="CompanyCountry"  styleClass="standardText" value="#{agentProfileBean.compCountryId}">
    		<f:selectItem  itemLabel="#{messages['please.select']}" itemValue=""/>
    		<f:selectItems value="#{agentProfileBean.countryList}"/>
    		<a4j:support ajaxSingle="true" event="onclick" reRender="CompanyState,CompanyTerritory"></a4j:support>
    	</t:selectOneMenu>
    	
    	<h:outputText></h:outputText>
		<t:message for="CompanyState" styleClass="error"></t:message>
	    
	    <h:panelGroup>
			 <h:outputText value="*" styleClass="standardText_Mandatory" />
	   		<h:outputLabel for="CompanyState" value="#{messages['state']}" styleClass="standardText_Label" />
	    </h:panelGroup>
    	<t:selectOneMenu id="CompanyState"  styleClass="standardText" value="#{agentProfileBean.compStateId}">
    		<f:selectItem  itemLabel="#{messages['please.select']}" itemValue=""/>
    		<f:selectItems value="#{agentProfileBean.compStateList}"/>
    		<a4j:support ajaxSingle="true" event="onclick" reRender="CompanyTerritory"></a4j:support>
    	</t:selectOneMenu>
    	
    	<h:outputText></h:outputText>
		<t:message for="CompanyTerritory" styleClass="error"></t:message>
	    
	    <h:panelGroup>
			 <h:outputText value="*" styleClass="standardText_Mandatory" />
	   		<h:outputLabel for="CompanyTerritory" value="#{messages['territory']}" styleClass="standardText_Label" />
	    </h:panelGroup>
    	<t:selectOneMenu id="CompanyTerritory"  styleClass="standardText" value="#{agentProfileBean.compTerrId}">
    		<f:selectItem  itemLabel="#{messages['please.select']}" itemValue=""/>
    		<f:selectItems value="#{agentProfileBean.compTerritoryList}"/>
    	</t:selectOneMenu>
    	
    	
	    <h:outputText></h:outputText>
		<t:message for="TelephoneNoOffice" styleClass="error"></t:message>
	    
	    <h:outputLabel for="TelephoneNoOffice" value="#{messages['telephone.no']}" styleClass="standardText_Label" />
    	<t:inputText id="TelephoneNoOffice" required="false" size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.compTelno}">
    		<t:validateRegExpr pattern="\d{2}-\d{8}"/>
    	</t:inputText>
	    
	    <h:outputText></h:outputText>
		<t:message for="FaxNoOffice" styleClass="error"></t:message>	
	    
	    <h:outputLabel for="FaxNoOffice" value="#{messages['fax.no']}" styleClass="standardText_Label" />
    	<t:inputText id="FaxNoOffice" required="false" size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.compFaxno}">
    		<t:validateRegExpr pattern="\d{2}-\d{8}"/>
    	</t:inputText>
	</t:panelGrid>
	
	<h:panelGrid width="100%">
		<h:outputText value="#{messages['mailing.info']}"
			styleClass="sub_header" />
	</h:panelGrid>
	
	<t:panelGrid id="mailInfo" columns="2" columnClasses="standardTable_ColumnLeft_20,standardTable_ColumnLeft_80" width="100%">
	
		<h:outputText></h:outputText>
		<t:message for="MailBy" styleClass="error"></t:message>
		
		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" rendered="#{agentProfileBean.checkFlag}"/>
			<h:outputLabel for="MailBy" value="#{messages['mail.by']}"
				styleClass="standardText_Label" />
		</h:panelGroup>
		<h:panelGroup>
			<t:selectOneRadio id="MailBy" styleClass="standardText" value="#{agentProfileBean.mailBy}">
				<f:selectItems value="#{agentProfileBean.mailSelectList}"/>
				<a4j:support event="onclick" ajaxSingle="true" reRender="mailInfo"></a4j:support>
			</t:selectOneRadio>
		</h:panelGroup>
		
		<h:outputText></h:outputText>
		<t:message for="MailAddress1" styleClass="error"></t:message>
		
		<h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" rendered="#{agentProfileBean.checkFlag}"/>
			<h:outputLabel for="MailAddress1" value="#{messages['address']}" styleClass="standardText_Label" />
		</h:panelGroup>
		
	    <t:inputText id="MailAddress1" size="50" maxlength="50" readonly="#{!agentProfileBean.checkFlag}" required="#{agentProfileBean.checkFlag}" styleClass="standardText" value="#{agentProfileBean.agent.mailAddress1}"></t:inputText>
	     
	    <h:outputText></h:outputText>
		<t:message for="MailAddress2" styleClass="error"></t:message>
	     
	    <h:panelGroup></h:panelGroup>
	    <h:panelGroup>
	    	<t:inputText id="MailAddress2" readonly="#{!agentProfileBean.checkFlag}"  size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.mailAddress2}"></t:inputText>
	    </h:panelGroup>
	    
	    <h:outputText></h:outputText>
		<t:message for="MailPostcode" styleClass="error"></t:message>
	    
	    <h:panelGroup>
			<h:outputText value="*" styleClass="standardText_Mandatory" rendered="#{agentProfileBean.checkFlag}"/>
			<h:outputLabel for="MailPostcode" value="#{messages['postcode']}" styleClass="standardText_Label" />
		</h:panelGroup>
	    <t:inputText id="MailPostcode"  size="50" maxlength="5" readonly="#{!agentProfileBean.checkFlag}" required="#{agentProfileBean.checkFlag}" styleClass="standardText" value="#{agentProfileBean.agent.mailPostcode}">
	    		<t:validateRegExpr pattern="\d{5}|\d{4}"/>
	    </t:inputText>
	    
	    <h:outputText></h:outputText>
		<t:message for="MailCity" styleClass="error"></t:message>
	    
	    <h:panelGroup>
			 <h:outputText value="*" styleClass="standardText_Mandatory" rendered="#{agentProfileBean.checkFlag}"/>
			 <h:outputLabel for="MailCity" value="#{messages['city']}" styleClass="standardText_Label" />
		</h:panelGroup>	
		<t:inputText  id="MailCity" readonly="#{!agentProfileBean.checkFlag}" required="#{agentProfileBean.checkFlag}" size="50" maxlength="50" styleClass="standardText" value="#{agentProfileBean.agent.mailCity}"></t:inputText>
	    	
	    <h:outputText></h:outputText>
		<t:message for="MailCountry" styleClass="error"></t:message>
	    
	     <h:panelGroup>
			 <h:outputText value="*" styleClass="standardText_Mandatory" rendered="#{agentProfileBean.checkFlag}"/>
			 <h:outputLabel for="MailCountry" value="#{messages['country']}" styleClass="standardText_Label" />
		</h:panelGroup>
    	<t:selectOneMenu  id="MailCountry" readonly="#{!agentProfileBean.checkFlag}" required="#{agentProfileBean.checkFlag}"  styleClass="standardText" value="#{agentProfileBean.mailCountryId}">
    		<f:selectItem  itemLabel="#{messages['please.select']}" itemValue=""/>
    		<f:selectItems value="#{agentProfileBean.countryList}"/>
    		<a4j:support ajaxSingle="true" event="onclick" reRender="MailState"></a4j:support>
    	</t:selectOneMenu>
	    
	    <h:outputText></h:outputText>
		<t:message for="MailState" styleClass="error"></t:message>
	    
	    <h:panelGroup>
			 <h:outputText value="*" styleClass="standardText_Mandatory" rendered="#{agentProfileBean.checkFlag}"/>
			 <h:outputLabel for="MailState" value="#{messages['state']}" styleClass="standardText_Label" />
		</h:panelGroup>
    	<t:selectOneMenu  id="MailState" readonly="#{!agentProfileBean.checkFlag}" required="#{agentProfileBean.checkFlag}"  styleClass="standardText" value="#{agentProfileBean.mailStateId}">
    		<f:selectItem  itemLabel="#{messages['please.select']}" itemValue=""/>
    		<f:selectItems value="#{agentProfileBean.mailStateList}"/>
    	</t:selectOneMenu>
	    
	    
	</t:panelGrid>
	
	<rich:spacer height="30"></rich:spacer>
	
	<t:panelGrid columns="2" columnClasses="standardTable_ColumnLeft_20,standardTable_ColumnLeft_80" width="100%">
		<t:outputText></t:outputText>
		<t:panelGroup>
		 	<h:commandButton value="#{messages['update']}" styleClass="button"  action="#{agentProfileBean.updateAgentProfileAction}"></h:commandButton>
		 	<f:verbatim>&nbsp;</f:verbatim>
   			<h:commandButton value="#{messages['back']}" styleClass="button" action="#{agentProfileBean.backAction}"  immediate="true"></h:commandButton>
   		</t:panelGroup>
	</t:panelGrid>
	
</rich:panel>